package com.apes.auto.car.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @ClassName CarSeries
 * @Description 车系
 * @Author pengyb
 * @Date 2019/7/11 10:18
 * @Version 1.0
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CarSeries.CONST_TABLE_NAME,indexes = {
        @Index(columnList = "name"),
        @Index(columnList = "name,brandMessages_id")
})
public class CarSeries extends Model {
    public static final String CONST_TABLE_NAME = "dc_car_series";

    @Id
    @Column(name = "id", length = 30)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "车系")
    private String id;  //编码

    @Column(name = "name", length = 200)
    @Comment("车系名称")
    private String name;// 名称

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "brandMessages_id", referencedColumnName = "id", nullable = false)
    @Comment("品牌")
    private CarBrand carBrand;  //品牌

}
